import java.util.Arrays;

/**
 * Created by zhangjinrui on 17/6/27.
 */

public class Solution467 {

    public static void main(String args[]) {
        Solution467 s = new Solution467();
        System.out.println(s.findSubstringInWraproundString("zaa"));
    }

    public int findSubstringInWraproundString(String p) {
        if (p.length() == 0) {
            return 0;
        }
        int count[] = new int[26];

        int length = 0;

        for (int i = 0; i < p.length(); i++) {
            char b = p.charAt(i);
            if (i != 0 && (b - p.charAt(i - 1) == 1 || b - p.charAt(i - 1) == -25)) {
                length++;
            } else {
                length = 1;
            }
            count[b - 'a'] = Math.max(length, count[b - 'a']);
        }

        int sum = 0;
        for (int i = 0; i < 26; i++) {
            sum += count[i];
        }

        return sum;
    }

}
